package com.su.lesson02;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseMotionListener;

public class testActionTwo {
    public static void main(String[] args) {
       Frame frame = new Frame();

       Button button1 = new Button("Start");
       Button button2 = new Button("Stop");
       MyMoitor myMoitor = new MyMoitor();

       button1.addActionListener(myMoitor);
       button2.addActionListener(myMoitor);
        //可以显示定义触发会返回的命令，若18行没定义，默认显示标题，
        //可以使用多个按钮通用

       button1.setActionCommand("999");
       frame.add(button1, BorderLayout.NORTH);
       frame.add(button2, BorderLayout.SOUTH);

       frame.pack();
       frame.setVisible(true);
    }
}
class MyMoitor implements ActionListener{
    @Override
    public void actionPerformed(ActionEvent e) {
        //e.getActionCommand()获取按钮上的一些信息

        System.out.println("按钮被点击了" + e.getActionCommand());
    }
}
